function sendMessage(name, onFulffiled, onRejected) {
  console.log(
    `邓哥 -> ${name}: 最近由谣言说我喜欢你，我要澄清一下，那不是谣言`
  );
  console.log(`等待${name}回复......`);

  setTimeout(() => {
    if (Math.random() <= 0.1) {
      onFulffiled(`${name} -> 邓哥：我是九，你是三，除了你还是你`);
    } else {
      onRejected(`${name} -> 邓哥：你是个好人`);
    }
  }, 100);
}

/* sendMessage(
  "李建刚",
  (reply) => {
    console.log("成功", reply);
  },
  (reason) => {
    console.log("失败", reason);
  }
); */

function sendMessage1(name) {
  return new Promise((resolve, reject) => {
    console.log(
      `邓哥 -> ${name}: 最近由谣言说我喜欢你，我要澄清一下，那不是谣言`
    );
    console.log(`等待${name}回复......`);

    setTimeout(() => {
      if (Math.random() <= 0.1) {
        resolve(`${name} -> 邓哥：我是九，你是三，除了你还是你`);
      } else {
        reject(`${name} -> 邓哥：你是个好人`);
      }
    }, 100);
  });
}

sendMessage1("李建刚").then(
  (reply) => {
    console.log("成功！", reply);
  },
  (reason) => {
    console.log("失败!", reason);
  }
);
